package com.lintcode.solution;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution_50 {
    public static void main(String[] args) {
        Integer[] longs = { 1, 2, 3 };
        List<Integer> list = Arrays.asList(longs);
        System.out.println(productExcludeItself(list));
    }
    
    public static List<Long> productExcludeItself(List<Integer> nums) {
        List<Long> list = new ArrayList<>(nums.size());
        int size = nums.size();
        for (int i = 0; i < size; i++) {
            Long item = 1L;
            for (int j = 0; j < size; j++) {
                if (j != i) {
                    item *= nums.get(j);
                }
            }
            
            list.add(item);
        }
        return list;
    }
}
